//
//  CreditsLayer.m
//
//  Source file for the credits menu which shows
//  the developers for the app as well as credits
//  for the game components such as music and art

#import "CreditsLayer.h"
#import "MainMenuLayer.h"
#import "GameState.h"
#import "SimpleAudioEngine.h"

static const int kCreditsTitleSize = 104;
static const int knameSize = 60;
static const int ksfuSize = 25;

@implementation CreditsLayer

// returns a scene object containing the current layer
// this essentially loads the "screen" for a
// particular section or part of the game
+(CCScene *) scene
{
	CCScene *scene = [CCScene node];
    CreditsLayer *layer = [CreditsLayer node];
    
	[scene addChild: layer];
	
	return scene;
}

-(void) mainMenuPressed
{
    [[CCDirector sharedDirector] replaceScene:[CCTransitionFade
                                               transitionWithDuration:0.3 scene:[MainMenuLayer scene]]];
    [[SimpleAudioEngine sharedEngine] playEffect:@"Menu_Click.wav"];
}

-(id) init
{
    if ((self = [super init])) {
        CGSize winSize = [[CCDirector sharedDirector] winSize];
        
        CCSprite *bg = [CCSprite spriteWithFile:@"menuBackground.png"];
        bg.position = ccp(winSize.width / 2, winSize.height / 2);
        [self addChild:bg z:0];
        
        CCLabelTTF *creditsTitleLbl = [CCLabelTTF labelWithString:@"Credits" fontName:@"Marker Felt" fontSize:kCreditsTitleSize];
        creditsTitleLbl.position = ccp(winSize.width / 2, winSize.height - kCreditsTitleSize);
        creditsTitleLbl.color = ccc3(255, 255, 255);
        [self addChild:creditsTitleLbl];
        
        //our team name
        CCLabelTTF *teamLbl = [CCLabelTTF labelWithString:@"Team Majik" fontName:@"Marker Felt" fontSize:knameSize];
        teamLbl.position = ccp(winSize.width / 2, winSize.height - 200);
        teamLbl.color = ccc3(255, 255, 255);
        [self addChild:teamLbl];
        
        CCLabelTTF *clarenceLbl = [CCLabelTTF labelWithString:@"Clarence Chuahuico" fontName:@"Marker Felt" fontSize:knameSize];
        clarenceLbl.position = ccp(winSize.width / 2, winSize.height - 300);
        clarenceLbl.color = ccc3(255, 255, 255);
        [self addChild:clarenceLbl];
        
        CCLabelTTF *adrianLbl = [CCLabelTTF labelWithString:@"Adrian Lam" fontName:@"Marker Felt" fontSize:knameSize];
        adrianLbl.position = ccp(winSize.width / 2, winSize.height - 350);
        adrianLbl.color = ccc3(255, 255, 255);
        [self addChild:adrianLbl];

        CCLabelTTF *jonathanLbl = [CCLabelTTF labelWithString:@"Jonathan Lee" fontName:@"Marker Felt" fontSize:knameSize];
        jonathanLbl.position = ccp(winSize.width / 2, winSize.height - 400);
        jonathanLbl.color = ccc3(255, 255, 255);
        [self addChild:jonathanLbl];
        
        CCLabelTTF *markoLbl = [CCLabelTTF labelWithString:@"Marko Mitrovic" fontName:@"Marker Felt" fontSize:knameSize];
        markoLbl.position = ccp(winSize.width / 2, winSize.height - 450);
        markoLbl.color = ccc3(255, 255, 255);
        [self addChild:markoLbl];

        CCLabelTTF *alanLbl = [CCLabelTTF labelWithString:@"Alan Wong" fontName:@"Marker Felt" fontSize:knameSize];
        alanLbl.position = ccp(winSize.width / 2, winSize.height - 500);
        alanLbl.color = ccc3(255, 255, 255);
        [self addChild:alanLbl];
        
        CCLabelTTF *sfuLbl = [CCLabelTTF labelWithString:@"A PRODUCT OF SIMON FRASER UNIVERSITY - CMPT275" fontName:@"Marker Felt" fontSize:ksfuSize];
        sfuLbl.position = ccp(winSize.width / 2, winSize.height - 600);
        sfuLbl.color = ccc3(255, 255, 255);
        [self addChild:sfuLbl];
        
        CCMenuItemImage *menuBtn = [CCMenuItemImage itemWithNormalImage:@"mainMenuButton.png"
                                                          selectedImage:@"mainMenuButtonHighlight.png" target:self selector:@selector(mainMenuPressed)];
        
        CCMenu *mainMenu = [CCMenu menuWithItems:menuBtn, nil];
        
        mainMenu.position = ccp(mainMenu.position.x, 50);
        [self addChild:mainMenu];
        
    }
    
    return self;
}

@end
